package com.jeeplus.modules.flowable.listener;

import com.jeeplus.modules.flowable.myListenerService.service.MyJianLongListenterService;
import org.flowable.engine.delegate.TaskListener;
import org.flowable.engine.impl.el.FixedValue;
import org.flowable.task.service.delegate.DelegateTask;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

@Component()
//@ComponentScan()
public class RepairAcceptanceListener  implements TaskListener {
    /**
     * dubbo的类名
     */

    private FixedValue clazzName;
    /**
     * 方法名
     */
    private FixedValue method;
    /**
     * 版本号
     */
    private FixedValue version;
    /**
     * 参数 多个的话用分号隔开 实例 userCode:00004737;status:1
     */
    private FixedValue params;

    @Autowired
    private MyJianLongListenterService myListenerService;

    private static RepairAcceptanceListener repairAcceptanceListener;
    @PostConstruct
    public void init(){
        repairAcceptanceListener = this;
        repairAcceptanceListener.myListenerService = this.myListenerService;
    }

    @Override
    public void notify(DelegateTask delegateTask) {
        String processInstanceId = delegateTask.getProcessInstanceId();
        String eventName = delegateTask.getEventName();
        if ("start".equals(eventName)) {
        } else if ("assignment".equals(eventName)) {
        } else if ("complete".equals(eventName)) {
        } else if ("delete".equals(eventName)) {
            repairAcceptanceListener.myListenerService.insertRepairAcceptance(delegateTask.getProcessInstanceId(),delegateTask.getProcessDefinitionId());
        } else if ("create".equals(eventName)) {
        }
    }
}